package com.wp.common.config;

import lombok.Data;

@Data
public class R {
    private int code;
    private String msg;
    private Object data;

    public R() {
    }

    public R(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static R setR(int c, String m, Object o) {
        return new R(c, m, o);
    }

    /**
     * 成功 返回数据
     */
    public static R ok(Object obj) {
        return setR(0, "OK", obj);
    }

    /**
     * 成功
     */
    public static R ok() {
        return ok(null);
    }

    /**
     * 失败 返回内容
     */
    public static R fail(String m) {
        return setR(1, m, null);
    }

    /**
     * 失败
     */
    public static R fail() {
        return fail("FAIL");
    }
}
